var gulp = require('gulp');  
var ngAnnotate = require('gulp-ng-annotate');
var uglify = require('gulp-uglify');  
var concat = require('gulp-concat');

gulp.task('minForm', function() {  
    gulp.src([
        'angular-form/base/form-delete.js',
        'angular-form/base/form-edit-simple.js',
        'angular-form/base/form-init.js',
        'angular-form/base/form-search.js',
        'angular-form/base/form-selected.js',
        'angular-form/base/form-tree-edit-simple.js',
        'angular-form/base/form-tree-init.js',
        'angular-form/base/form-tree-search.js',
        'angular-form/child/form-child-simple.js',
        'angular-form/data/data-simple.js',
        'angular-form/dictionary/dictionary.js',
        'angular-form/router-ctrl.js',
        'angular-form/form.js']) //注意，此处特意如此，避免顺序导致的问题
        .pipe(ngAnnotate())
        .pipe(concat('form.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest('dest/form'));

    return gulp.src([
        'angular-form/base/form-delete.js',
        'angular-form/base/form-edit-simple.js',
        'angular-form/base/form-init.js',
        'angular-form/base/form-search.js',
        'angular-form/base/form-selected.js',
        'angular-form/base/form-tree-edit-simple.js',
        'angular-form/base/form-tree-init.js',
        'angular-form/base/form-tree-search.js',
        'angular-form/child/form-child-simple.js',
        'angular-form/data/data-simple.js',
        'angular-form/dictionary/dictionary.js',
        'angular-form/router-ctrl.js',
        'angular-form/form.js']) //注意，此处特意如此，避免顺序导致的问题
        .pipe(concat('form.js'))
        .pipe(gulp.dest('dest/form'));
});

gulp.task('minGis', function() {  
	gulp.src([
    	'angular-gis/gis/base/toolbar.js',
    	'angular-gis/gis/locator/locator.js',
    	'angular-gis/gis/config.js',
    	'angular-gis/gis/gis.js'
    	]) //注意，此处特意如此，避免顺序导致的问题
        .pipe(ngAnnotate())
        .pipe(concat('gis.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest('dest/gis'));

    gulp.src([
    	'angular-gis/gis/base/toolbar.js',
    	'angular-gis/gis/locator/locator.js',
    	'angular-gis/gis/config.js',
    	'angular-gis/gis/gis.js'
    	]) //注意，此处特意如此，避免顺序导致的问题
        .pipe(ngAnnotate())
        .pipe(concat('gis.js'))
        .pipe(gulp.dest('dest/gis'));

    gulp.src([
    	'angular-gis/arcgis3/base/arcgis-draw.js',
    	'angular-gis/arcgis3/base/arcgis-geoservice.js',
    	'angular-gis/arcgis3/base/arcgis-graphic.js',
    	'angular-gis/arcgis3/base/arcgis-measure.js',
    	'angular-gis/arcgis3/base/arcgis-printing.js',
    	'angular-gis/arcgis3/base/arcgis-toolbar.js',
    	'angular-gis/arcgis3/base/arcgis-utils.js',
    	'angular-gis/arcgis3/base/arcgis-base.js',
    	'angular-gis/arcgis3/locator/arcgis-locator.js',
    	'angular-gis/arcgis3/map/arcgis-map-base.js',
    	'angular-gis/arcgis3/map/arcgis-map-layer.js',
    	'angular-gis/arcgis3/map/arcgis-map-ui.js',
    	'angular-gis/arcgis3/map/arcgis-map.js',
    	'angular-gis/arcgis3/search/arcgis-search-attribute.js',
    	'angular-gis/arcgis3/search/arcgis-search-find.js',
    	'angular-gis/arcgis3/search/arcgis-search-identify.js',
    	'angular-gis/arcgis3/search/arcgis-search-result-mutli.js',
    	'angular-gis/arcgis3/search/arcgis-search-result-simple.js',
    	'angular-gis/arcgis3/search/arcgis-search-space.js',
    	'angular-gis/arcgis3/search/arcgis-search-utils.js',
    	'angular-gis/arcgis3/search/arcgis-search.js',
    	'angular-gis/arcgis3/ui/arcgis-ui-page.js',
    	'angular-gis/arcgis3/ui/arcgis-ui.js',
    	'angular-gis/arcgis3/arcgis.js'
    	]) //注意，此处特意如此，避免顺序导致的问题
        .pipe(ngAnnotate())
        .pipe(concat('arcgis3.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest('dest/gis'));

	gulp.src([
    	'angular-gis/arcgis3/base/arcgis-draw.js',
    	'angular-gis/arcgis3/base/arcgis-geoservice.js',
    	'angular-gis/arcgis3/base/arcgis-graphic.js',
    	'angular-gis/arcgis3/base/arcgis-measure.js',
    	'angular-gis/arcgis3/base/arcgis-printing.js',
    	'angular-gis/arcgis3/base/arcgis-toolbar.js',
    	'angular-gis/arcgis3/base/arcgis-utils.js',
    	'angular-gis/arcgis3/base/arcgis-base.js',
    	'angular-gis/arcgis3/locator/arcgis-locator.js',
    	'angular-gis/arcgis3/map/arcgis-map-base.js',
    	'angular-gis/arcgis3/map/arcgis-map-layer.js',
    	'angular-gis/arcgis3/map/arcgis-map-ui.js',
    	'angular-gis/arcgis3/map/arcgis-map.js',
    	'angular-gis/arcgis3/search/arcgis-search-attribute.js',
    	'angular-gis/arcgis3/search/arcgis-search-find.js',
    	'angular-gis/arcgis3/search/arcgis-search-identify.js',
    	'angular-gis/arcgis3/search/arcgis-search-result-mutli.js',
    	'angular-gis/arcgis3/search/arcgis-search-result-simple.js',
    	'angular-gis/arcgis3/search/arcgis-search-space.js',
    	'angular-gis/arcgis3/search/arcgis-search-utils.js',
    	'angular-gis/arcgis3/search/arcgis-search.js',
    	'angular-gis/arcgis3/ui/arcgis-ui-page.js',
    	'angular-gis/arcgis3/ui/arcgis-ui.js',
    	'angular-gis/arcgis3/arcgis.js'
    	]) //注意，此处特意如此，避免顺序导致的问题
        .pipe(ngAnnotate())
        .pipe(concat('arcgis3.js'))
        .pipe(gulp.dest('dest/gis'));

    gulp.src([
    	'angular-gis/cesium1/base/cesium-draw.js',
    	'angular-gis/cesium1/base/cesium-graphic.js',
    	'angular-gis/cesium1/base/cesium-toolbar.js',
    	'angular-gis/cesium1/base/cesium-utils.js',
    	'angular-gis/cesium1/base/cesium-base.js',
    	'angular-gis/cesium1/locator/cesium-locator.js',
    	'angular-gis/cesium1/map/cesium-map-base.js',
    	'angular-gis/cesium1/map/cesium-map-layer.js',
    	'angular-gis/cesium1/map/cesium-map-ui.js',
    	'angular-gis/cesium1/map/cesium-map.js',
    	'angular-gis/cesium1/cesium.js'
    	]) //注意，此处特意如此，避免顺序导致的问题
        .pipe(ngAnnotate())
        .pipe(concat('cesium1.js'))
        .pipe(gulp.dest('dest/gis'));

    return gulp.src([
    	'angular-gis/cesium1/base/cesium-draw.js',
    	'angular-gis/cesium1/base/cesium-graphic.js',
    	'angular-gis/cesium1/base/cesium-toolbar.js',
    	'angular-gis/cesium1/base/cesium-utils.js',
    	'angular-gis/cesium1/base/cesium-base.js',
    	'angular-gis/cesium1/locator/cesium-locator.js',
    	'angular-gis/cesium1/map/cesium-map-base.js',
    	'angular-gis/cesium1/map/cesium-map-layer.js',
    	'angular-gis/cesium1/map/cesium-map-ui.js',
    	'angular-gis/cesium1/map/cesium-map.js',
    	'angular-gis/cesium1/cesium.js'
    	]) //注意，此处特意如此，避免顺序导致的问题
        .pipe(ngAnnotate())
        .pipe(concat('cesium1.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest('dest/gis'));
}); 

gulp.task('minSecurity', function() {  
    gulp.src(['angular-security/security.js'])
        .pipe(ngAnnotate())
        .pipe(concat('security.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest('dest/security'));
    gulp.src(['angular-security/security.js'])
        .pipe(ngAnnotate())
        .pipe(concat('security.js'))
        .pipe(gulp.dest('dest/security'));
});

gulp.task('minUI', function() {  
    gulp.src([
        'angular-ui/easyui/base/ui-datebox.js',
        'angular-ui/easyui/base/ui-hide-novalidate.js',
        'angular-ui/easyui/base/ui-include.js',
        'angular-ui/easyui/base/ui-tabs.js',
        'angular-ui/easyui/base/ui-textarea.js',
        'angular-ui/easyui/base/ui-window.js',
        'angular-ui/easyui/base/easyui-base.js',
        'angular-ui/easyui/extend/as-chinese-bool.js',
        'angular-ui/easyui/extend/as-chinese-date.js',
        'angular-ui/easyui/extend/as-date.js',
        'angular-ui/easyui/extend/as-length.js',
        'angular-ui/easyui/extend/as-empty.js',
        'angular-ui/easyui/extend/easyui-extend.js',
        'angular-ui/easyui/form/ui-combo.js',
        'angular-ui/easyui/form/ui-combobox.js',
        'angular-ui/easyui/form/ui-combotree.js',
        'angular-ui/easyui/form/ui-date.js',
        'angular-ui/easyui/form/ui-dep.js',
        'angular-ui/easyui/form/ui-page.js',
        'angular-ui/easyui/form/ui-tree.js',
        'angular-ui/easyui/form/ui-user.js',
        'angular-ui/easyui/form/easyui-form.js',
        'angular-ui/easyui/easyui.js',
        ])
        .pipe(ngAnnotate())
        .pipe(concat('easyui.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest('dest/ui'));

    gulp.src([
        'angular-ui/easyui/base/ui-datebox.js',
        'angular-ui/easyui/base/ui-hide-novalidate.js',
        'angular-ui/easyui/base/ui-include.js',
        'angular-ui/easyui/base/ui-tabs.js',
        'angular-ui/easyui/base/ui-textarea.js',
        'angular-ui/easyui/base/ui-window.js',
        'angular-ui/easyui/base/easyui-base.js',
        'angular-ui/easyui/extend/as-chinese-bool.js',
        'angular-ui/easyui/extend/as-chinese-date.js',
        'angular-ui/easyui/extend/as-date.js',
        'angular-ui/easyui/extend/as-length.js',
        'angular-ui/easyui/extend/as-empty.js',
        'angular-ui/easyui/extend/easyui-extend.js',
        'angular-ui/easyui/form/ui-combo.js',
        'angular-ui/easyui/form/ui-combobox.js',
        'angular-ui/easyui/form/ui-combotree.js',
        'angular-ui/easyui/form/ui-date.js',
        'angular-ui/easyui/form/ui-dep.js',
        'angular-ui/easyui/form/ui-page.js',
        'angular-ui/easyui/form/ui-tree.js',
        'angular-ui/easyui/form/ui-user.js',
        'angular-ui/easyui/form/easyui-form.js',
        'angular-ui/easyui/easyui.js',
        ])
        .pipe(ngAnnotate())
        .pipe(concat('easyui.js'))
        .pipe(gulp.dest('dest/ui'));

    gulp.src([
        'angular-ui/extend/charts/ui-echarts.js'
        ])
        .pipe(ngAnnotate())
        .pipe(concat('ui-echarts.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest('dest/ui'));

    gulp.src([
        'angular-ui/extend/edit/ui-edit.js'
        ])
        .pipe(ngAnnotate())
        .pipe(concat('ui-edit.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest('dest/ui'));
    gulp.src([
        'angular-ui/extend/upload/as-files.js',
        'angular-ui/extend/upload/ui-upload.js'
        ])
        .pipe(ngAnnotate())
        .pipe(concat('ui-upload.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest('dest/ui'));
});